﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using WP.Commons;
using WP.DB;
using WP.Modules;
using WP.Controls;
using WP.Controls.GridColumn;


using WP.RM.BusinessRule;
using WP.RM.BusinessLogical;
using WP.RM.DataAccess;

namespace WP.RM.Form
{
    public partial class frmRMWKWorkCostLookup : BaseQryRpt 
    {
        public frmRMWKWorkCostLookup()
        {
            InitializeComponent();
            LoadAllControl(new ArrayList(this.Controls));
            this.MinimumSize = this.Size;
        }


        public void ShowWorkCost(DBAccess dbcon , string strCategoryID, string strSetID, string strProductFItemID, string strVersionNo, double dblTotWorkCost)//计算关键工序的成本
        {

            string strSQL = "select sum(DetailCost),sum(DetailTotWorkCost) from rmProductBOMLabourCostRev where CategoryID='{0}' and SetID='{1}' and ProductFItemID='{2}' and VersionNo='{3}' and IsKeyWK=1";
            strSQL = string.Format(strSQL, strCategoryID, strSetID, strProductFItemID, strVersionNo);
            DataRow drTotal = dbcon.GetDataFirstRow(strSQL);
            if (drTotal != null)
            {
                txtKeyWKWorkCost.Text = BaseFunctions.FormatNumeric(CvtFunc.ToDouble(drTotal[1]), "Ns.2");
            }
            txtOtherWorkCost.Text = BaseFunctions.FormatNumeric(dblTotWorkCost - CvtFunc.ToDouble(txtKeyWKWorkCost.Text), "Ns.2");
            txtTotalWorkCost2.Text = BaseFunctions.FormatNumeric ( dblTotWorkCost, "Ns.2");

            this.ShowDialog(); 
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
